#ifndef _M_CONSUMER_H_
#define _M_CONSUMER_H_

#include <iostream>
#include <google/protobuf/map.h>
#include <string>
#include <vector>
#include <cassert>
#include <sstream>
#include <functional>
#include <mutex>
#include <unordered_map>
#include <string>

#include "../mqcommon/mqProto.pb.h"
#include "../mqcommon/logger.hpp"
#include "../mqcommon/helper.hpp"

namespace MyRabbitMQ
{
    namespace NSConsumer
    {
        using Callback = std::function<void(const std::string&, const protoMQ::BaseProperties*,const std::string&)>;
    };
    //消费者类
    class Consumer
    {
    public:
        using ptr = std::shared_ptr<Consumer>;

        Consumer()
        :m_name("nullptr")
        ,m_subscriptionQueue("parent_nullptr")
        ,m_autoAck(false)
        ,m_callback(nullptr)
        {
            LOG(logLevel::INFO) << "创建了空消费者" << std::endl;
        }

        Consumer(const std::string& name, const std::string& qname, bool autoAck ,
        const MyRabbitMQ::NSConsumer::Callback& callback)
        :m_name(name)
        ,m_subscriptionQueue(qname)
        ,m_autoAck(autoAck)
        ,m_callback(std::move(callback))
        {
            LOG(logLevel::INFO) << "创建了消费者: " << this->m_name << std::endl;
        }
        
        ~Consumer()
        {
            LOG(logLevel::INFO) << "删除了消费者:" << this->m_name << std::endl; 
        }

    public:
        std::string m_name;
        std::string m_subscriptionQueue;
        bool m_autoAck;
        MyRabbitMQ::NSConsumer::Callback m_callback;
    };
};

#endif